package vip.liux.backend.application.service.point;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.factory.Mappers;
import vip.liux.contracts.infrastructure.automap.IgnoreAudited;
import vip.liux.contracts.infrastructure.automap.MapMapper;
import vip.liux.contracts.infrastructure.automap.MapStructConfig;
import vip.liux.contracts.models.point.PointsAccount;
import vip.liux.contracts.models.point.PointsRule;
import vip.liux.contracts.models.point.PointsTransaction;

import java.util.List;

@Mapper(config = MapStructConfig.class, uses = {MapMapper.class})
public interface AutoMapperProfile {

    AutoMapperProfile INSTANCE = Mappers.getMapper(AutoMapperProfile.class);

    @IgnoreAudited
    PointsRule toEntity(PointsRuleService.PointsRuleCreateDto input);

    @IgnoreAudited
    void toEntity(PointsRuleService.PointsRuleCreateDto input, @MappingTarget PointsRule target);

    PointsRuleDto toDto(PointsRule source);

    List<PointsRuleDto> toRuleDtos(List<PointsRule> source);

    @Mapping(target = "user", ignore = true)
    PointsTransactionDto toDto(PointsTransaction transaction);

    PointsAccountDto toDto(PointsAccount source);
}
